import 'package:flutter/material.dart';

import 'package:get/get.dart';
import '../controllers/course_detail_controller.dart';

class CourseDetailView extends GetView<CourseDetailController> {
  @override
  CourseDetailController controller = Get.put(CourseDetailController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('课堂记录照'),
        centerTitle: true,
      ),
      body: GetBuilder<CourseDetailController>(
        assignId: true,
        builder: (logic) {
          return Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              RaisedButton(
                onPressed: controller.takePhoto,
                child: Text('拍照'),
              ),
              RaisedButton(
                onPressed: controller.takeVideo,
                child: Text('录像'),
              ),
              _imageView(controller.imagePath,controller.videoPath),
              RaisedButton(
                onPressed: controller.upLoadImg,
                child: Text('上传'),
              ),
            ],
          );
        },
      ),
    );
  }

  /*图片控件*/
  Widget _imageView(imgPath,videoPath) {
    if (imgPath == null&&videoPath == null) {
      print('🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱🐱');
      return Expanded(
        child: Text("请选择拍照或录像"),
      );
    } else {
      return Expanded(
        child: Container(
          child: controller.imagePath==null?Image.file(controller.videoPath):
          Image.file(controller.imagePath),
        ),
      );
    }
  }
}
